package top.rainbowecho.notify.infrastructure.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.rainbowecho.common.mq.config.BlogMqRouteEnum;
import top.rainbowecho.common.mq.listener.ListenerConfig;

/**
 * @author rainbow
 * @since 2020/4/8 15:23
 */
@Configuration
public class SmsListenerConfig extends ListenerConfig {

    @Bean
    public Queue smsQueue() {
        return new Queue(getRouting(BlogMqRouteEnum.SMS));
    }

    @Bean
    public TopicExchange smsExchange() {
        return new TopicExchange(getExchange(BlogMqRouteEnum.SMS));
    }

    @Bean
    public Binding smsBinding() {
        return BindingBuilder.bind(smsQueue()).to(smsExchange()).with(getRouting(BlogMqRouteEnum.SMS));
    }
}
